<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>相对类类型</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="language.types.never.html">« Never</a></li>
      <li style="float: right;"><a href="language.types.literal.html">literal 类型 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="language.types.html">类型</a></li>
    <li>相对类类型</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="language.types.relative-class-types" class="sect1">
 <h2 class="title">相对类类型</h2>

 <p class="para">
  这些类型声明只能在类中使用。
 </p>

 <div class="sect2" id="language.types.relative-class-types.self">
  <h3 class="title"><span class="type"><span class="type self">self</span></span></h3>
  <p class="para">
   The value must be an <a href="language.operators.type.html" class="link"><code class="literal">instanceof</code></a> the same class as the one
   in which the type declaration is used.
  </p>
 </div>

 <div class="sect2" id="language.types.relative-class-types.parent">
  <h3 class="title"><span class="type"><span class="type parent">parent</span></span></h3>
  <p class="para">
   值必须是 <a href="language.operators.type.html" class="link"><code class="literal">instanceof</code></a> 使用了类型声明的父级类。
  </p>
 </div>

 <div class="sect2" id="language.types.relative-class-types.static">
  <h3 class="title">static</h3>
  <p class="para">
   <span class="type"><span class="type static">static</span></span> is a return-only type which requires that the
   value returned must be an <a href="language.operators.type.html" class="link"><code class="literal">instanceof</code></a> the same class as the one
   the method is called in.
   自 PHP 8.0.0 起可用。
  </p>
 </div>

</div></div></div></body></html>